package hot100;

import DTO.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class inorderTraversal2 {
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> ret = new ArrayList<>();
        dfs(ret,root);
        return ret;
    }

    public void dfs(List<Integer> ret,TreeNode root) {
        if(root == null) {
            return;
        }
        dfs(ret,root.left);
        ret.add(root.val);
        dfs(ret,root.right);
    }
}
